package com.rhit.rosehack.SQLObjects;

import lombok.Data;

public @Data class Item implements SQLObject
{
	/**
	 * 8 bytes...
	 * bytes 0-3 are for attack mod
	 * bytes 4-7 are for defense mod
	 * bytes 8-11 are for hp mod
	 */
    private int ID;
    private String name;
    private long stats;
    private char symbol;
    private int x, y;
    
    public void setStats( long stats )
    {
    	if( ( stats & 0xFFFFL ) != 0 )
    		symbol = 'w';
    	else if( ( stats & ( 0xFFFFL << 16 ) ) != 0 )
    		symbol = 'd';
    	else if( ( stats & ( 0xFFFFL << 32 ) ) != 0 )
    		symbol = 'h';
    	else
    		symbol = '.';
    	
    	this.stats = stats;
    }
    
    public void setAttackModifier( int mod )
    {
    	stats &= (~0xFFFFL);
    	stats |= ( (long)mod & 0xFFFFL ); 
    	symbol = 'w';
    }

    public void setDefenseModifier( int mod )
    {
    	stats &= ( ~( 0xFFFFL << 16 ) );
    	stats |= ( ( (long)mod & 0xFFFFL ) << 16 );
    	symbol = 'd';
    }

    public void setHPModifier( int mod )
    {
    	stats &= ( ~( 0xFFFFL << 32 ) );
    	stats |= ( ( (long)mod & 0xFFFFL ) << 32 );
    	symbol = 'h';
    }
    
    public int getAttackModifier()
    {
    	return ( int )( stats & ( 0xFFFFL ) );
    }
    
    public int getDefenseModifier()
    {
    	return ( int )( ( stats & ( 0xFFFFL << 16 ) ) >> 16 );
    }
    
    public int getHPModifier()
    {
    	return ( int )( ( stats & ( 0xFFFFL << 32 ) ) >> 32 );
    }
}
